<?php
//author:wangyinghao
namespace app\index\controller;
use think\Controller;
use think\Request;
use think\Db;
use app\index\model\Index as UserModel;
use app\index\model\Dynamic as UserModel2;

class Index extends Controller
{
	
	
	
	public function find_Attennum($per_id)
    {
    	
    	$count = Db::name('focus')
         ->where('focus', $per_id)
         ->count();
         $this->assign('atten',$count); 
    	
    }
    
    public function detail2()
	{
		return $this->fetch();
	}
	public function detail1()
	{
		$list = UserModel::all();
        return view('read',['list'=>$list]);
	}
    
    public function index()
    {
    	$per_id=111;
    	
    	
//  $arr = Array('one', 'two', 'three');
//   echo json_encode($arr);
    	
//  	$data = Db::name('user')->find();
        $this->assign('result', '333');
        $countfocus = Db::name('focus')
         ->where('focus_id', $per_id)
         ->count();
         $this->assign('atten',$countfocus); 
         //获取关注数量
         $countfans = Db::name('focus')
         ->where('foucsed_id', $per_id)
         ->count();
         $this->assign('fans',$countfans); 
         //获取粉丝数量
         
         $countdynamic = Db::name('dynamic')
         ->where('user_id', $per_id)
         ->count();
         $this->assign('dycount',$countdynamic);
         //获取动态数量
         $seatright = Db::name('user')
         ->where('user_id', $per_id)
         ->value('motto');
//       ->find();
         $this->assign('seatrt',$seatright);
         //取得关注数列表
         $focusId = Db::name('focus')
         ->where('focus_id', $per_id)
         ->column('foucsed_id');
//       ->find();
         $this->assign('fouId',$focusId);
         $list=UserModel2::paginate(8);
		$this->assign('list',$list);
		$this->assign('count',count($list));
		return view('index');
       //获取座右铭
        return $this->fetch();
//  	 $list = UserModel::all();
//  foreach ($list as $user) {
//  	{
//  	$query->where('focus_id', '151110132');
//  });
//      echo $user->nickname . '<br/>';
//      echo $user->email . '<br/>';
//      echo date('Y/m/d', $user->birthday) . '<br/>';
//      echo 
//      echo '----------------------------------<br/>';
//  }
//      return '<style type="text/css">*{ padding: 0; margin: 0; } .think_default_text{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> ThinkPHP V5<br/><span style="font-size:30px">十年磨一剑 - 为API开发设计的高性能框架</span></p><span style="font-size:22px;">[ V5.0 版本由 <a href="http://www.qiniu.com" target="qiniu">七牛云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_bd568ce7058a1091"></thinkad>';
//      return 'hello.';
  }
  
  public  function find_User($per_id)
  {
  	$result = Db::name('user')
    ->where('user_id', $per_id)
    ->find();
    dump($result);
  }
    
    public function find_Fansnum($per_id)
    {
    	$count = Db::name('focus')
    ->where('focused_id', $per_id)
    ->count();
     dump($count);   
    }
    
    
    public function find_Fans($per_id)
    {
    	$result = Db::name('focus')
       ->where('focused_id', $per_id)
       ->find();
       dump($result);
    }
   
    
	
   

    

}
?>

